#pragma once
#include<iostream>
#include<time.h>
#include<string.h>
#include<string>
std::string opers="+-*/%";

enum
{
    DEFAULT,
    MUL_ERRNO,
};
template <class T>
class Task
{   
public:
    Task(T x,T y,char oper)
        :_data1(x),_data2(y),_result(T()),_exitcode(DEFAULT),_oper(oper)
    {}
    void run()
    {
        switch(_oper)
        {
            case '+':
                _result=_data1+_data2;
                break;
            case '-':
                _result=_data1-_data2;
                break;
            case '*':
                _result=_data1*_data2;
                break;
            case '/':
                if(_data2==T())
                    _exitcode=MUL_ERRNO;
                else
                _result=_data1/_data2;
                break;
            case '%':
                if(_data2==T())
                    _exitcode=MUL_ERRNO;
                else
                    _result=_data1%_data2;
                break;
            default:
                _exitcode=DEFAULT;
                break;
        }
    }
    void operator()()
    {
        run();
    }
    std::string gettask()
    {
        std::string r=std::to_string(_data1);
        r+=_oper;
        r+=std::to_string(_data2);
        r+="=?";
        return r;
    }
    std::string getresult()
    {
        std::string r=std::to_string(_data1);
        r+=_oper;
        r+=std::to_string(_data2);
        r+="=";
        r+=std::to_string(_result);
        r+="[code:";
        r+=std::to_string(_exitcode);
        r+="]";
        return r;
    }
    ~Task(){}
private:
    T _data1;
    T _data2;;
    int _exitcode;
    T _result;
    char _oper;
};